﻿import LuminicBox.Log.ConsolePublisher;
import org.aswing.AttachIcon;
import org.aswing.BorderLayout;
import org.aswing.debug.Log;
import org.aswing.FlowLayout;
import org.aswing.JButton;
import org.aswing.JFrame;
import org.aswing.JLabel;
import org.aswing.JPanel;
import org.aswing.plaf.custom.parser.css.CSSDocument;
import org.aswing.plaf.custom.parser.ParserLog;
import org.aswing.plaf.custom.parser.XMLStyleParser;
import org.aswing.UIManager;
import org.aswing.plaf.custom.CustomLookAndFeel;
import org.aswing.plaf.winxp.WinXpLookAndFeel;
import LuminicBox.Log.Logger;
import org.aswing.util.Delegate;

class LAFTest extends JFrame
{
	private var buttonsPanel:JPanel;
	private var labelPanel:JPanel;
	private var okBtn : JButton;
	private var cancelBtn : JButton;
	private var title : String;
	private var message : String;
	private var messageDisplay:JLabel;
	
	public function LAFTest (title:String ,message:String) 
	{
		
		super (_root, true);
		this.title=title;
		this.message=message;
		
		var info:AttachIcon =new AttachIcon("INFO",51,43);
		var buttonsPanel:JPanel =new JPanel();
		var labelPanel:JPanel =new JPanel();
		okBtn = new JButton ("Ok", info);
		//okBtn.setPreferredSize(75,22);
		cancelBtn = new JButton ("Cancel");
		cancelBtn.setPreferredSize(75,22);
		messageDisplay = new JLabel(message,info);
		
		
		
		buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT,20,8));
		buttonsPanel.append(okBtn);
		buttonsPanel.append(cancelBtn);
		
		labelPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
		labelPanel.append(messageDisplay);
		
		getContentPane().append(labelPanel, BorderLayout.EAST);
		getContentPane().append(buttonsPanel, BorderLayout.SOUTH);
		setTitle(title);
	}
	
	private static var docXML:XML;
	
	public static function main (Void) : Void
	{	var lv:LoadVars = new LoadVars();	
		lv.onData = function (src){	
				
				try{
					var laf:CustomLookAndFeel = new CustomLookAndFeel();
					laf.setCSSStyle(src);
					UIManager.setLookAndFeel(laf);					
				}catch(e:Error){
					UIManager.setLookAndFeel(new WinXpLookAndFeel())
				}
				
				//var reader:CSSDocument = new CSSDocument(src);
				ParserLog.getInstance().traceLog();
				
				var myWindow : LAFTest = new LAFTest ("Information","ASWing ROCKS!!");
				myWindow.setLocation (50, 50);
				myWindow.setSize (200, 200);
				//myWindow.setResizable(false);
				myWindow.show ();
				myWindow.messageDisplay.revalidate();
			
				_root.test.text="hello";
		}
		lv.load("style.css");
		
	}	
		
	private static var logger:Logger;
	public static function trace(msg:String){
		if(logger == null){
			logger = new Logger();
			logger.addPublisher(new ConsolePublisher());
		}
		logger.log(msg)
	}
}
